package com.micro.modual.service.impl;

import com.micro.common.MicroResponseCode;
import com.micro.core.exception.BizException;
import com.micro.core.frame.service.impl.AbstractBasicsServiceImpl;
import com.micro.core.resp.RespJson;
import com.micro.modual.entity.Assemble;
import com.micro.modual.extension.AssembleExtension;
import com.micro.modual.mapper.AssembleMapper;
import com.micro.modual.model.bo.assemble.AssembleBO;
import com.micro.modual.service.AssembleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
*  <h1>拼团表  实现</h1>
 * @author LevelCoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:11:10
 */
@Service("assembleService")
public class AssembleServiceImpl extends AbstractBasicsServiceImpl<Assemble,Long> implements AssembleService {

    @Autowired
    private AssembleMapper assembleMapper;

    /**
     * <h2>新增拼团表详情</h2>
     * @param assembleBO {@link AssembleBO} 拼团表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson addAssemble(AssembleBO assembleBO) {
        Assemble assemble = AssembleExtension.converAddAssemble(assembleBO);
        assembleMapper.insertSelective(assemble);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(), MicroResponseCode.SUCCESS.getResponseMessage());
    }

    /**
     * <h2>修改拼团表详情</h2>
     * @param assembleBO  {@link AssembleBO} 拼团表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson editAssemble(AssembleBO assembleBO) {
        Assemble assemble = AssembleExtension.converEditAssemble(assembleBO);
        assembleMapper.updateByPrimaryKeySelective(assemble);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());

    }

    /**
     * <h2>根据主键编号删除拼团表信息</h2>
     * @param id  拼团表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */

    @Override
    public RespJson deleteAssemble(Long id) {
        assembleMapper.deleteByPrimaryKey(id);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());
    }

}
